// 客户端
import {request} from './request.js'

// 上传头像
function uploadAvatar(img) {
  return request({
    url: '/avatar',
    method: 'post',
    data: img,
    headers: {'Content-Type': 'multipart/form-data'},
  })
}

// 上传文章
function sendTopic({tag, title, content, author}) {
  return request({
    url: '/thread',
    method: 'post',
    data: {
      tag,
      title,
      content,
      author
    }
  })
}

// 上传评论
function sendComment({content, thread_id}) {
  return request({
    url: '/comment',
    method: 'post',
    data: {content, thread_id}
  })
}

// 修改密码
function modPwd({oldpwd, newpwd}) {
  return request({
    url: 'pwd',
    method: 'post',
    data: {oldpwd, newpwd}
  })
}
// 修改密码
function sendCommentZan({comment_id}) {
  return request({
    url: '/zan',
    method: 'post',
    data: {
      comment_id
    }
  })
}

export default {uploadAvatar, sendTopic, sendComment,sendCommentZan, modPwd}
